package com.ehais.model;




import java.util.Arrays;
import java.util.List;

public class NewScanBatteryData {
    public NewScanBatteryData(){
        super();
    }

    public NewScanBatteryData(Battery battery){
        super();
        this.monomerNumber = 4;// StringUtils.isNotBlank(battery.getMonomerNumber()) ? Integer.valueOf(battery.getMonomerNumber()) : 0;
        this.model = battery.getModel();
        this.batteryId = 101L;// battery.getId();
        this.dischargedTime = "0";
        this.soc = "0";
    }

    private Integer monomerNumber;//24 4
    private String model;//2V 12V
    private String type;//  plumbic / Phosphoric
    private List<Double> monomerVoltageList;//单体单压的数值
    private List<Double> temperatureList;//单体单压的数值


    //////////////////////////////////////////////////////////////////////////铁锂的参数
    private String address;
    private Integer alarmElectricity;
    private Integer alarmVoltage;
    private Double electricity;
    private Double voltage;

    //////////////////////////////////////////////////////////////////////////需要上传的数据
    private String batterySurfaceTem;
    private Double current = 0D; // 电流
    private String dischargedTime;//todo 放电时长（放电电流为负值时开始计时，单位为分钟）
    private String monomerVoltageAverage;
    private String soc;//todo 电池放电容量（上面的累计放电时长*当前电流值，单位为安时AH）
    private String PCBInternalTem;
    private String busVoltage;
    private String acquisitionTime;//采集时间
    private Long batteryId; //电池ID



    public Boolean getAlarmTotalVoltage() {//检验总电压是否告警
        if(this.type.equals("plumbic")){
            this.voltage = 0D;
            for(Double v : monomerVoltageList){
                this.voltage += v;
            }
            if(this.voltage  <= 46.5 && this.voltage >= 56){
                return true;
            }
        }else if(this.type.equals("Phosphoric")){
            if(this.voltage  <= 48.5 && this.voltage >= 56){
                return true;
            }
        }
        return false;
    }

    public Boolean getAlarmMonomerVoltage(Double _voltage){// 单体电压告警
        if(this.type.equals("plumbic")){
            if(monomerNumber == 24 && _voltage <= 1.5D && _voltage >= 4D){
                return true;
            }else if(monomerNumber == 4 && _voltage <= 8D && _voltage >= 15D){
                return true;
            }
        }else if(this.type.equals("Phosphoric")){
            if(_voltage <= 48.5D){
                return true;
            }
        }
        return false;
    }

    public Boolean getAlarmElectricity(){
        if(this.type.equals("plumbic")){
            if(electricity <= -150 && electricity >= 0){
                return true;
            }
        }else if(this.type.equals("Phosphoric") && this.alarmElectricity > 0){
            return true;
        }
        return false;
    }

    public Boolean getAlarmMonomerTemperature(Double _temperatur){ // 单体温度告警
        if(this.type.equals("Phosphoric")){
            if(_temperatur >= 50){
                return true;
            }
        }
        return false;
    }

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    public Integer getMonomerNumber() {
        return monomerNumber;
    }

    public void setMonomerNumber(Integer monomerNumber) {
        this.monomerNumber = monomerNumber;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<Double> getMonomerVoltageList() {
        return monomerVoltageList;
    }

    public void setMonomerVoltageList(List<Double> monomerVoltageList) {
        this.monomerVoltageList = monomerVoltageList;
    }

    public List<Double> getTemperatureList() {
        return temperatureList;
    }

    public void setTemperatureList(List<Double> temperatureList) {
        this.temperatureList = temperatureList;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public void setAlarmElectricity(Integer alarmElectricity) {
        this.alarmElectricity = alarmElectricity;
    }

    public Integer getAlarmVoltage() {
        return alarmVoltage;
    }

    public void setAlarmVoltage(Integer alarmVoltage) {
        this.alarmVoltage = alarmVoltage;
    }

    public Double getElectricity() {
        return electricity;
    }

    public void setElectricity(Double electricity) {
        this.electricity = electricity;
    }

    public Double getVoltage() {
        return voltage;
    }

    public void setVoltage(Double voltage) {
        this.voltage = voltage;
    }

    public String getBatterySurfaceTem() {
        return batterySurfaceTem;
    }

    public void setBatterySurfaceTem(String batterySurfaceTem) {
        this.batterySurfaceTem = batterySurfaceTem;
    }

    public Double getCurrent() {
        return current;
    }

    public void setCurrent(Double current) {
        this.current = current;
    }

    public String getDischargedTime() {
        return dischargedTime;
    }

    public void setDischargedTime(String dischargedTime) {
        this.dischargedTime = dischargedTime;
    }

    public String getMonomerVoltageAverage() {
        return monomerVoltageAverage;
    }

    public void setMonomerVoltageAverage(String monomerVoltageAverage) {
        this.monomerVoltageAverage = monomerVoltageAverage;
    }

    public String getSoc() {
        return soc;
    }

    public void setSoc(String soc) {
        this.soc = soc;
    }

    public String getPCBInternalTem() {
        return PCBInternalTem;
    }

    public void setPCBInternalTem(String PCBInternalTem) {
        this.PCBInternalTem = PCBInternalTem;
    }

    public String getBusVoltage() {
        return busVoltage;
    }

    public void setBusVoltage(String busVoltage) {
        this.busVoltage = busVoltage;
    }

    public String getAcquisitionTime() {
        return acquisitionTime;
    }

    public void setAcquisitionTime(String acquisitionTime) {
        this.acquisitionTime = acquisitionTime;
    }

    public Long getBatteryId() {
        return batteryId;
    }

    public void setBatteryId(Long batteryId) {
        this.batteryId = batteryId;
    }
}
